<template>
    <footer class="margin-top-15 bg-fff padding-bottom-10" >
        <compWrapper
            title="操作日志"
            theme="gray"
        >
            <Table class="margin-10 margin-right-10" :columns="columns" size="small" :data="data" ref="table" :loading="loading" border stripe></Table>
        </compWrapper>
    </footer>
</template>

<script>
import { HttpRecordList } from '@/service/api/views';

export default {
    props:['id'],
	data() {
		return {
			loading: true,
			data: [],
		};
	},
	mounted() {
		this.getList({ id: this.$route.params.id || this.id });
	},
	methods: {
		async getList(formdata) {
			this.loading = true;
			let response = await HttpRecordList(formdata).catch(res => {
				this.loading = false;
			});
			if (response) {
				this.loading = false;
				this.data = response.data.content || [];
			}
		},
	},
	computed: {
		columns() {
			return [
				{
					title: 'NO',
					key: 'NO',
					width: 60,
					type: 'index',
				},
				{
					title: '操作类型',
					key: 'opAction',
					render(h, { row }) {
						let type = null;
						switch (row.opAction) {
							case 'create':
								type = '创建';
								break;
							case 'update':
								type = '更新';
								break;
							default:
								type = '导入';
								break;
						}
						return h('span', type);
					},
				},
				{
					title: '操作人',
					key: 'opUserName',
				},
				{
					title: '备注',
					key: 'opRemark',
				},
				{
					title: '操作时间',
					key: 'opAt',
				},
			];
		},
	},
};
</script>
